<%--
    Document   : add_warehouse
    Created on : Nov 6, 2009, 4:23:47 AM
    Author     : moustafa
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@page import="java.util.ArrayList" %>
<%@page import="java.util.Iterator" %>
<%@page import="model.Warehouse" %>
<%@page import="model.Product" %>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
   "http://www.w3.org/TR/html4/loose.dtd">

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>New Inventory</title>
    </head>
    <body onload="setTimeout('document.getElementById(\'message\').innerHTML=\'<br/>\'', 2500)">
        <%
            String message = (String)request.getSession(false).getAttribute("added_message");
            request.getSession(false).setAttribute("added_message", null);
        %>
        <p align="center" style="color:green" id="message"><%=message != null ? message : "<br/>"%></p>

        <form action="../admin/addinventory">
            <%
            ArrayList<Warehouse> warehouses = (ArrayList<Warehouse>)request.getSession(false).getAttribute("warehouses");
            ArrayList<Product> products = (ArrayList<Product>)request.getSession(false).getAttribute("products");
            %>
        <table border="1" cellspacing="1" cellpadding="1">
            <tbody>
                <tr>
                    <td>Warehouse: </td>
                    <td>
                        <select name="warehouse_id">
                            <option value="-1" selected="true">Select Warehouse</option>
                            <%
                            Iterator<Warehouse> warehousesItr = warehouses.iterator();
                            Warehouse warehouse;
                            while(warehousesItr.hasNext()){
                                warehouse = warehousesItr.next();
                                %>
                                <%=
                                "<option value="+warehouse.getID()+">"+warehouse.getName()+"</option>"
                                %>
                                <%
                            }
                            %>
                        </select>
                    </td>
                </tr>
                <tr>
                    <td>Product: </td>
                    <td>
                        <select name="product_id">
                            <option value="-1" selected="true">Select Product</option>
                            <%
                            Iterator<Product> productsItr = products.iterator();
                            Product product;
                            while(productsItr.hasNext()){
                                product = productsItr.next();
                                %>
                                <%=
                                "<option value="+product.getID()+">"+product.getName()+"</option>"
                                %>
                                <%
                            }
                            %>
                        </select>
                    </td>
                </tr>
                <tr>
                    <td>Quantity: </td>
                    <td>
                        <select name="quantity">
                            <option value="-1" selected="true">Select Quantity</option>
                            <%
                            for(int i = 0; i < 30; i++){
                                %>
                                <%=
                                "<option value="+ i +">"+ i +"</option>"
                                %>
                                <%
                            }
                            %>
                        </select>
                    </td>
                </tr>
            </tbody>
        </table>
            <input type="submit" value="Create Inventory" />
        </form>
        <form action="../admin/inventories">
            <input type="submit" value="Go Back"/>
        </form>
    </body>
</html>
